********************************************************************************
********************************************************************************
*																			   *
* 		Replication file for "Social group appeals in party rhetoric:          *
*			 Effects on policy support and polarization"				       *
*																			   *
* 		by Lena Maria Huber, Thomas M. Meyer, and Markus Wagner		   		   *
*                  published in The Journal of Politics                        *
*																			   *
********************************************************************************
********************************************************************************


clear
clear mata 
clear matrix
version 16.1
set more off
set scrollbufsize 50000
set mem 512M, 
set scheme sj
set trace off
capture log close

*** set your working directories for data & results (tables & figures)
global DATA "YOUR_DIR_FOR_DATA" // e.g. "C:\Users\Default\Desktop"
global TABLES "YOUR_DIR_FOR_TABLES"
global FIGURES "YOUR_DIR_FOR_FIGURES"


graph set window fontface "Latin Modern Math"


*** install additional packages
ssc install estout, replace
net install gr0034, from(http://www.stata-journal.com/software/sj8-2/) replace

********************************************************************************
*** Main analysis
********************************************************************************


***** Results from Study I
cd "$DATA"
use "Study_1.dta", clear

xtset id

*** Regression Table
xtreg evaluation ib2.condition  i.group  if positive == 1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_pos

xtreg evaluation ib2.condition##c.sympathy i.group  if positive == 1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_pos

										
xtreg evaluation ib2.condition  i.group if positive == 0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_neg

xtreg evaluation ib2.condition##c.sympathy i.group if positive == 0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_neg	 
		 
			 
			 
*** Graphs
* following the ideas of Xu, Hainmueller, Mummolo, Liu 
* ("INTERFLEX: Stata module to estimate multiplicative interaction models with diagnostics and visualization")
* -> yet, their package only works for treatment/control (two groups)


*** Positive appeals
xtile symp_xtile = sympathy if positive == 1, nquantiles(4)
tab symp_xtile, gen(G)
tab symp_xtile sympathy if positive == 1

forval i=1/4 {
    tabstat sympathy if positive == 1 & symp_xtile == `i', statistics(median) save
	local median = r(StatTotal)[1,1]
	gen centered_symp`i' = sympathy-`median' if positive == 1
}
bysort symp_xtile: egen median_symp = median(sympathy) if positive == 1


tab condition, gen(D)
forval i=1/4 {
	gen centered_symp`i'_G`i' = centered_symp`i'*G`i'
	forval j=1/3 { 
		gen D`j'_G`i' = D`j'*G`i'
		gen D`j'_centered_symp`i'_G`i' = D`j'*centered_symp`i'*G`i'	
	}
}

* note: for bins G3 & G4 there is only one category -> centered_symp3_G3 & centered_symp3_G4 are constant & dropped from the model 
* reference category: D3 (condition==2)
xtreg evaluation i.G1 D1_G1 D3_G1 centered_symp1_G1 D1_centered_symp1_G1 D3_centered_symp1_G1  /// 
				 i.G2 D1_G2 D3_G2 centered_symp2_G2 D1_centered_symp2_G2 D3_centered_symp2_G2  ///
				 i.G3 D1_G3 D3_G3 centered_symp3_G3 D1_centered_symp3_G3 D3_centered_symp3_G3  ///
				 i.G4 D1_G4 D3_G4 centered_symp4_G4 D1_centered_symp4_G4 D3_centered_symp4_G4  ///
				 i.group if positive == 1, fe vce(cluster id)
est sto m2_bin


gen effect = .
gen lower = .
gen upper = .

forval i=1/4 {
	est restore m2_bin
	margins, dydx(D3_G`i') post
	matrix b = e(b)
	matrix Var = e(V)

	matrix list b 
	matrix list Var

	replace effect = b[1,1] if symp_xtile == `i'
	replace upper = b[1,1]+1.96*sqrt(Var[1,1]) if symp_xtile == `i'
	replace lower = b[1,1]-1.96*sqrt(Var[1,1]) if symp_xtile == `i'
}


est restore m2_pos
margins, dydx(3.condition) at(sympathy=(0(1)10)) 
marginsplot, ///
	addplot((scatter effect median_symp, mcolor(black) ) || ///
	(rcap upper lower median_symp, lcolor(black)) || ///
	(histogram  sympathy  if positive==1, below fintensity(100) ///
	color(gs10%30) yaxis(2) yscale(alt off range(0 3) axis(2)) ytitle("", axis(2)) 	ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding positive group appeal") ///
	xtitle("Group affect") ///
	title(" Study I ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_positive_st1.gph", replace
drop median_symp symp_xtile effect  upper lower
drop D? D?_* centered_* G?


*** Negative appeals
xtile symp_xtile = sympathy if positive == 0, nquantiles(4)
tab symp_xtile, gen(G)
tab symp_xtile sympathy if positive == 0

forval i=1/4 {
    tabstat sympathy if positive == 0 & symp_xtile == `i', statistics(median) save
	local median = r(StatTotal)[1,1]
	gen centered_symp`i' = sympathy-`median' if positive == 0
}
bysort symp_xtile: egen median_symp = median(sympathy) if positive == 0


tab condition, gen(D)
forval i=1/4 {
	gen centered_symp`i'_G`i' = centered_symp`i'*G`i'
	forval j = 1/3 { 
		gen D`j'_G`i' = D`j'*G`i'
		gen D`j'_centered_symp`i'_G`i' = D`j'*centered_symp`i'*G`i'	
	}
}

* reference category: D3 (condition==2)
xtreg evaluation i.G1 D1_G1 D3_G1 centered_symp1_G1 D1_centered_symp1_G1 D3_centered_symp1_G1  /// 
				 i.G2 D1_G2 D3_G2 centered_symp2_G2 D1_centered_symp2_G2 D3_centered_symp2_G2  ///
				 i.G3 D1_G3 D3_G3 centered_symp3_G3 D1_centered_symp3_G3 D3_centered_symp3_G3  ///
				 i.G4 D1_G4 D3_G4 centered_symp4_G4 D1_centered_symp4_G4 D3_centered_symp4_G4  ///
				 i.group if positive == 0, fe vce(cluster id)
est sto m2_bin


gen effect = .
gen lower = .
gen upper = .

forval i=1/4 {
	est restore m2_bin
	margins, dydx(D3_G`i') post
	matrix b = e(b)
	matrix Var = e(V)

	matrix list b 
	matrix list Var

	replace effect = b[1,1] if symp_xtile == `i'
	replace upper = b[1,1]+1.96*sqrt(Var[1,1]) if symp_xtile == `i'
	replace lower = b[1,1]-1.96*sqrt(Var[1,1]) if symp_xtile == `i'
}


est restore m2_neg
margins, dydx(3.condition) at(sympathy=(0(1)10)) 
marginsplot, ///
	addplot((scatter effect median_symp, mcolor(black) ) || ///
	(rcap upper lower median_symp, lcolor(black)) || ///
	(histogram sympathy if positive == 0, below fintensity(100) ///
	color(gs10%30) yaxis(2) yscale(alt off range(0 3) axis(2)) ytitle("", axis(2)) 	ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding negative group appeal") ///
	xtitle("Group affect") ///
	title("Study I", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_negative_st1.gph", replace

drop median_symp symp_xtile effect upper lower
drop D? D?_* centered_* G?

*** Extremism & Polarisation
gen gr_id = _n in 1/18
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Artists" 3 "Disabled people" 4 "Families" 5 "Homosexuals" 6 "Pensioners" 7 "Police officers" 8 "Rural residents" 9 "Women" 10 " " 11 "Pooled: negative group appeals" 12 "Car drivers" 13 "Civil servants" 14 "Criminals" 15 "Foreigners" 16 "Muslims" 17 "Politicians" 18 "Rich people" 
label values gr_id  gr_id_lbl

gen gr_sort = 1 if gr_id == 1
replace gr_sort = 2 if gr_id > 1 & gr_id <= 10
replace gr_sort = 3 if gr_id == 11
replace gr_sort = 4 if gr_id > 11 & gr_id <= 18

gen treat = .
gen treat_upper = .
gen treat_lower = .	
gen group_vs_policy = .	


* dependent variable: extremism of attitude
gen ext_eval = sqrt((evaluation-5)^2)


* magnitude of the effect
sum ext_eval if positive == 1
sum ext_eval if positive == 0

tabstat ext_eval if positive == 1, stat(sd) by(group)
tabstat ext_eval if positive == 0, stat(sd) by(group)


reg ext_eval ib2.condition if group == 15
est store m_ext_art
reg ext_eval ib2.condition if group == 3
est store m_ext_disable
reg ext_eval ib2.condition if group == 4
est store m_ext_family
reg ext_eval ib2.condition if group == 6
est store m_ext_homosex
reg ext_eval ib2.condition if group == 9
est store m_ext_pension
reg ext_eval ib2.condition if group == 14
est store m_ext_police
reg ext_eval ib2.condition if group == 7
est store m_ext_rural
reg ext_eval ib2.condition if group == 5
est store m_ext_women
reg ext_eval ib2.condition if group == 1
est store m_ext_car
reg ext_eval ib2.condition if group == 2
est store m_ext_civil
reg ext_eval ib2.condition if group == 11
est store m_ext_crime
reg ext_eval ib2.condition if group == 10
est store m_ext_foreigner
reg ext_eval ib2.condition if group == 12
est store m_ext_muslim
reg ext_eval ib2.condition if group == 13
est store m_ext_politician
reg ext_eval ib2.condition if group == 8
est store m_ext_rich


xtreg ext_eval ib2.condition i.group if positive == 1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_ext_pos
										
xtreg ext_eval ib2.condition i.group if positive == 0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_ext_neg


*** Table F.1: Extremism: positive appeals (Study I)
cd "$TABLES"
esttab m1_ext_pos m_ext_art m_ext_disable m_ext_family m_ext_homosex m_ext_pension m_ext_police m_ext_rural m_ext_women ///
			 using "tab_f1.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles("Pooled: positive" "Artists" "Disabled people" "Families" "Homosexuals" ///
			 "Senior citizens" "Police officers" "Rural residents" "Women") ///
			 title("Extremism: positive appeals (Study I)") ///
			 drop(*.group) /// 
			 order(1.condition 3.condition ) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal") ///
			 scalars("respondents FEs respondents" "groupFE FEs groups" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")
			 

			 
*** Table F.3: Extremism: negative appeals (Study I)			 
cd "$TABLES"
esttab m1_ext_neg m_ext_car m_ext_civil m_ext_crime m_ext_foreigner m_ext_muslim m_ext_politician m_ext_rich ///
			 using "tab_f3.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles("Pooled: negative" "Car drivers" "Civil servants" "Criminals" ///
			 "Foreigners" "Muslims" "Politicians" "Rich people") ///
			 title("Extremism: negative appeals (Study I)") ///
			 drop(*.group) order(1.condition 3.condition ) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal") ///
			 scalars("respondents FEs respondents" "groupFE FEs groups" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")			 
 
			 
est restore m1_ext_pos
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 1
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 1
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 1

	 
est restore m_ext_art
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 2
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 2
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 2

est restore m_ext_disable
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 3
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 3
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 3


est restore m_ext_family
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 4
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 4
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 4


est restore m_ext_homosex
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat=b[1,2] if gr_id == 5
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 5
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 5


est restore m_ext_pension
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 6
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 6
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 6


est restore m_ext_police
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 7
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 7
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 7


est restore m_ext_rural
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 8
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 8
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 8

			 
est restore m_ext_women
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 9
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 9
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 9


est restore m1_ext_neg
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 11
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 11
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 11
	 
est restore m_ext_car
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 12
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 12
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 12

est restore m_ext_civil
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat=b[1,2] if gr_id == 13
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 13
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 13

est restore m_ext_crime
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 14
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 14
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 14

est restore m_ext_foreigner
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 15
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 15
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 15

est restore m_ext_muslim
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 16
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 16
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 16

est restore m_ext_politician
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 17
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 17
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 17

est restore m_ext_rich
margins, dydx(3.condition) post 
matrix b = r(b)
matrix V = e(V)
replace treat = b[1,2] if gr_id == 18
replace treat_upper = b[1,2]+1.96*sqrt(V[2,2]) if gr_id == 18
replace treat_lower = b[1,2]-1.96*sqrt(V[2,2]) if gr_id == 18
	
list gr_id treat in 1/18 
sort gr_sort (treat)
gen gr_id_sort = _n in 1/18
list gr_id treat gr_id_sort in 1/18 
decode gr_id, gen(gr_id_lbl_sort)
*replace gr_id_lbl_sort="" if gr_id==10
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 10 " ", modify
list gr_id treat gr_id_sort in 1/18, nolabel
list gr_id treat gr_id_sort in 1/18 


*** ATE for all groups
twoway (scatter gr_id_sort treat if gr_id_sort>=1 & gr_id_sort<=18, ///
		title("Study I", color(black))  ytitle(" ") ///
		xtitle("Marginal effect (extremism): adding group appeal", size(small)) ///
		graphregion(color(white)) mcolor(black) msize(small) ylabel(1(1)18, ///
		valuelabel angle(0) notick labsize(small) nogrid ) xlabel(, labsize(small)) ///
		xline(0, lcolor(black)) yscale(reverse) yline(10, lcolor(black))) || ///
		(rspike treat_upper treat_lower gr_id_sort if gr_id_sort>=1 & gr_id_sort<=18, ///
		horizontal lcolor(black) legend(off) xsize(6) ysize(5))

cd "$FIGURES"
graph save "fig_extreme_st1.gph", replace	

drop gr_id gr_sort gr_id_sort  gr_id_lbl_sort  ext_eval treat treat* group_vs_policy 
label drop gr_id_lbl gr_id_lbl_sort


***** Results from Study II

cd "$DATA"
use "Study_2.dta", clear

xtset id

*** Regression Tables
xtreg evaluation ib1.condition i.group i.party if positive == 1 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_pos

xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group i.party if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m2_pos

xtreg evaluation ib1.condition##c.sympathy_group i.group i.party if positive == 1 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m3_pos

										
xtreg evaluation ib1.condition i.group i.party if positive==0 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_neg

xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group i.party if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m2_neg

xtreg evaluation ib1.condition##c.sympathy_group i.group i.party if positive == 0 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m3_neg
	 
			 
*** Graphs
* following the ideas of Xu, Hainmueller, Mummolo, Liu ("INTERFLEX: Stata module to estimate multiplicative interaction models with diagnostics and visualization")
* -> yet, their package only works for treatment/control (two groups)

xtile symp_xtile = sympathy_group if positive == 1, nquantiles(4) 
replace symp_xtile = 2 if sympathy_group == 5
tab symp_xtile, gen(G)
tab symp_xtile sympathy_group if positive == 1 

forval i=1/4 {
    tabstat sympathy_group if positive == 1 & symp_xtile == `i', statistics(median) save
	local median = r(StatTotal)[1,1]
	gen centered_symp`i' = sympathy_group - `median' if positive == 1
}
bysort symp_xtile: egen median_symp=median(sympathy_group) if positive == 1


tab condition, gen(D)
forval i=1/4 {
	gen centered_symp`i'_G`i'=centered_symp`i'*G`i'
	forval j=1/3 { 
		gen D`j'_G`i'=D`j'*G`i'
		gen D`j'_centered_symp`i'_G`i'=D`j'*centered_symp`i'*G`i'	
	}
}

* note: for bin G2 there is only one category -> centered_symp2_G2 is constant & dropped from the model 
* reference category: D3 (condition==1)
xtreg evaluation i.G1 D2_G1 D3_G1 centered_symp1_G1 D2_centered_symp1_G1 D3_centered_symp1_G1  /// 
				 i.G2 D2_G2 D3_G2 centered_symp2_G2 D2_centered_symp2_G2 D3_centered_symp2_G2  ///
				 i.G3 D2_G3 D3_G3 centered_symp3_G3 D2_centered_symp3_G3 D3_centered_symp3_G3  ///
				 i.G4 D2_G4 D3_G4 centered_symp4_G4 D2_centered_symp4_G4 D3_centered_symp4_G4  ///
				 i.group if positive == 1, fe vce(cluster id)
est sto m2_bin

gen effect = .
gen lower = .
gen upper = .

forval i=1/4 {
	est restore m2_bin
	margins, dydx(D3_G`i')  post
	matrix b=e(b)
	matrix Var=e(V)

	matrix list b 
	matrix list Var

	replace effect = b[1,1] if symp_xtile == `i'
	replace upper = b[1,1]+1.96*sqrt(Var[1,1]) if symp_xtile == `i'
	replace lower = b[1,1]-1.96*sqrt(Var[1,1]) if symp_xtile == `i'
}


*** Fig. 1: Marginal effect of adding positive group appeals on the evaluation of policy appeals 
est restore m2_pos
margins, dydx(3.condition) at(sympathy_group=(0(1)10)) 
marginsplot, ///
	addplot((scatter effect median_symp, mcolor(black) ) || ///
	(rcap upper lower median_symp, lcolor(black)) || ///
	(histogram  sympathy_group  if positive==1, below fintensity(100) ///
	color(gs10%30) yaxis(2) yscale(alt off range(0 3) axis(2)) ///
	ytitle("", axis(2)) ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') ///
	xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding positive group appeal ") ///
	xtitle("Group affect") ///
	title("Study II", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_positive_st2.gph", replace

graph combine fig_positive_st1.gph fig_positive_st2.gph, graphregion(color(white)) ysize(4) xsize(8) ycommon
graph export "fig_1.png", replace

erase fig_positive_st1.gph
erase fig_positive_st2.gph

drop median_symp symp_xtile effect upper lower
drop D? D?_* centered_* G?


*** Negative appeals
xtile symp_xtile = sympathy_group if positive == 0, nquantiles(4)
tab symp_xtile, gen(G)
tab symp_xtile sympathy_group if positive == 0

forval i=1/4 {
    tabstat sympathy_group if positive == 0 & symp_xtile == `i', statistics(median) save
	local median= r(StatTotal)[1,1]
	gen centered_symp`i' = sympathy_group - `median' if positive == 0
}
bysort symp_xtile: egen median_symp=median(sympathy_group) if positive == 0


tab condition, gen(D)
forval i=1/4 {
	gen centered_symp`i'_G`i'=centered_symp`i'*G`i'
	forval j=1/3 { 
		gen D`j'_G`i'=D`j'*G`i'
		gen D`j'_centered_symp`i'_G`i'=D`j'*centered_symp`i'*G`i'	
	}
}

* note: for bin G3 there is only one category -> centered_symp3_G3 is constant & dropped from the model 
* reference category: D3 (condition==1)
xtreg evaluation i.G1 D2_G1 D3_G1 centered_symp1_G1 D2_centered_symp1_G1 D3_centered_symp1_G1  /// 
				 i.G2 D2_G2 D3_G2 centered_symp2_G2 D2_centered_symp2_G2 D3_centered_symp2_G2  ///
				 i.G3 D2_G3 D3_G3 centered_symp3_G3 D2_centered_symp3_G3 D3_centered_symp3_G3  ///
				 i.G4 D2_G4 D3_G4 centered_symp4_G4 D2_centered_symp4_G4 D3_centered_symp4_G4  ///
				 i.group if positive == 0, fe vce(cluster id)
est sto m2_bin


gen effect = .
gen lower = .
gen upper = .

forval i=1/4 {
	est restore m2_bin
	margins, dydx(D3_G`i') post
	matrix b = e(b)
	matrix Var = e(V)

	matrix list b 
	matrix list Var

	replace effect = b[1,1] if symp_xtile == `i'
	replace upper = b[1,1]+1.96*sqrt(Var[1,1]) if symp_xtile == `i'
	replace lower = b[1,1]-1.96*sqrt(Var[1,1]) if symp_xtile == `i'
}


*** Fig. 2: Marginal effect of adding negative group appeals on the evaluation of policy appeals 
est restore m2_neg
margins, dydx(3.condition) at(sympathy_group=(0(1)10)) 
marginsplot, ///
	addplot((scatter effect median_symp, mcolor(black) ) || ///
	(rcap upper lower median_symp, lcolor(black)) || ///
	(histogram  sympathy_group  if positive==0, below fintensity(100) ///
	color(gs10%30) yaxis(2) yscale(alt off range(0 3) axis(2)) ///
	ytitle("", axis(2)) ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') ///
	xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding negative group appeal") ///
	xtitle("Group affect") ///
	title("Study II ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_negative_st2.gph", replace

graph combine fig_negative_st1.gph fig_negative_st2.gph, graphregion(color(white)) ysize(4) xsize(8) ycommon
graph export "fig_2.png", replace

erase fig_negative_st1.gph
erase fig_negative_st2.gph


drop median_symp symp_xtile effect upper lower
drop D? D?_* centered_* G?


*** Extremity & Polarisation
 
* Group variable
gen gr_id = _n in 1/16
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Unemployed" 3 "Car drivers" 4 "Muslims" 5 "Refugees" 6 "Artists" 7 "Homosexuals" 8 "East Germans" 9 " " 10 "Pooled: negative group appeals" 11 "Unemployed" 12 "Car drivers" 13 "Muslims" 14 "Foreigners" 15 "Rich people" 16 "Criminals" 
label values gr_id  gr_id_lbl

gen gr_sort = 1 if gr_id == 1
replace gr_sort = 2 if gr_id>1 & gr_id<=9
replace gr_sort = 3 if gr_id==10
replace gr_sort = 4 if gr_id>=11 & gr_id<=16


gen treat = .
gen treat_upper = .
gen treat_lower = .	
gen group_vs_policy = .	

gen ext_eval = sqrt((evaluation-5)^2)

* magnitude of the effect
sum ext_eval if positive == 1
sum ext_eval if positive == 0

tabstat ext_eval if positive == 1, stat(sd) by(group)
tabstat ext_eval if positive == 0, stat(sd) by(group)


reg ext_eval ib1.condition i.party if item==1
estadd local partyFE "Yes"
est store m_ext_unempl_pos
reg ext_eval ib1.condition i.party if item==3
estadd local partyFE "Yes"
est store m_ext_art
reg ext_eval ib1.condition i.party if item==6
estadd local partyFE "Yes"
est store m_ext_car_pos
reg ext_eval ib1.condition i.party if item==7
estadd local partyFE "Yes"
est store m_ext_homosex
reg ext_eval ib1.condition i.party if item==8
estadd local partyFE "Yes"
est store m_ext_muslim_pos
reg ext_eval ib1.condition i.party if item==12
estadd local partyFE "Yes"
est store m_ext_refugee
reg ext_eval ib1.condition i.party if item==13
estadd local partyFE "Yes"
est store m_ext_east

reg ext_eval ib1.condition i.party if item==2
estadd local partyFE "Yes"
est store m_ext_unempl_neg
reg ext_eval ib1.condition i.party if item==4
estadd local partyFE "Yes"
est store m_ext_rich
reg ext_eval ib1.condition i.party if item==5
estadd local partyFE "Yes"
est store m_ext_car_neg
reg ext_eval ib1.condition i.party if item==11
estadd local partyFE "Yes"
est store m_ext_muslim_neg
reg ext_eval ib1.condition i.party if item==9
estadd local partyFE "Yes"
est store m_ext_foreigner
reg ext_eval ib1.condition i.party if item==10
estadd local partyFE "Yes"
est store m_ext_criminals 


xtreg ext_eval ib1.condition i.group i.party if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_ext_pos
										
xtreg ext_eval ib1.condition i.group i.party if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_ext_neg


*** Table F.2: Extremism: positive appeals (Study II)
cd "$TABLES"
esttab m1_ext_pos m_ext_unempl_pos m_ext_car_pos  m_ext_muslim_pos m_ext_refugee m_ext_art  m_ext_homosex m_ext_east ///
			 using "tab_f2.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles( "Pooled: positive" "Unemployed" "Car drivers" "Muslims" ///
			 "Refugees"  "Artists"  "Homosexuals"  "East Germans") ///
			 title("Extremism: positive appeals (Study II)") ///
			 drop(*.party *.group) ///
			 order(2.condition 3.condition ) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal") ///	
             scalars("respondents FEs respondents"   "groupFE FEs groups" "partyFE FEs parties"  "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")


*** Table F.4: Extremism: negative appeals (Study II)			 
cd "$TABLES"
esttab m1_ext_neg m_ext_unempl_neg m_ext_car_neg m_ext_muslim_neg m_ext_foreigner m_ext_rich m_ext_criminals ///
			 using "tab_f4.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles("Pooled: negative" "Unemployed" "Car drivers" "Muslims" "Foreigners" "Rich people") ///
			 title("Extremism: negative appeals (Study II)") ///
			 drop(*.party *.group) ///
			 order(2.condition 3.condition) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal")	///	
             scalars("respondents FEs respondents"   "groupFE FEs groups" "partyFE FEs parties"  "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")			 
 			 
			
			 
est restore m1_ext_pos
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==1
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==1
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==1

           	 
est restore m_ext_unempl_pos
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==2
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==2
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==2


est restore m_ext_car_pos
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==3
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==3
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==3


est restore m_ext_muslim_pos
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==4
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==4
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==4


est restore m_ext_refugee
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==5
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==5
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==5


est restore m_ext_art
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==6
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==6
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==6


est restore m_ext_homosex
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==7
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==7
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==7


est restore m_ext_east
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==8
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==8
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==8


est restore m1_ext_neg
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==10
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==10
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==10

	 
est restore m_ext_unempl_neg
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==11
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==11
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==11
 

est restore m_ext_car_neg
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==12
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==12
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==12


est restore m_ext_muslim_neg
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==13
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==13
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==13


est restore m_ext_foreigner
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==14
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==14
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==14


est restore m_ext_rich
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==15
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==15
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==15


est restore m_ext_criminals
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==16
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==16
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==16


list gr_id treat in 1/16
sort gr_sort (treat)
gen gr_id_sort=_n in 1/16
list gr_id treat gr_id_sort in 1/16
decode gr_id, gen(gr_id_lbl_sort) 
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 9 " ", modify
list gr_id treat gr_id_sort in 1/16 , nolabel
list gr_id treat gr_id_sort in 1/16

	
	 
*** Fig. 3: Adding group appeals and polarization
twoway (scatter gr_id_sort treat  if gr_id_sort>=1 & gr_id_sort<=16, ///
	    title("Study II", color(black))  ytitle(" ") ///
		xtitle("Marginal effect (extremism): adding group appeal", size(small)) ///
		graphregion(color(white)) mcolor(black) msize(small) ///
		ylabel(1(1)16, valuelabel angle(0) notick labsize(small) nogrid ) ///
		xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse) ///
		yline(9, lcolor(black))) || ///
		(rspike treat_upper treat_lower gr_id_sort if gr_id_sort>=1 & gr_id_sort<=16, ///
		horizontal lcolor(black) legend(off) xsize(6) ysize(5))

cd "$FIGURES"
graph save "fig_extreme_st2.gph", replace	

graph combine fig_extreme_st1.gph fig_extreme_st2.gph, graphregion(color(white)) ysize(4) xsize(8) 
graph export "fig_3.png", replace

erase fig_extreme_st1.gph 
erase fig_extreme_st2.gph


drop gr_id gr_sort gr_id_sort gr_id_lbl_sort ext_eval treat treat* group_vs_policy 
label drop gr_id_lbl gr_id_lbl_sort


***********************************************************************************************************
*** Appendix B: Group selection
***********************************************************************************************************

* Content analysis of German election manifestos
cd "$DATA"
use "Party_manifestos.dta", clear	
		
*** Figure B.1
collapse (sum) count, by(cat)
tab cat

gsort -count
gen id=_n
drop if id>20

* all parties
graph bar count, horizontal bar(1,color(gs10)) over(cat, sort(1) descending) ytitle("Number of group appeals") graphregion(color(white))

cd "$FIGURES"
graph export "fig_b1.png", replace


***********************************************************************************************************
*** Appendix C: Descriptive statistics
***********************************************************************************************************
cd "$DATA"
use "Study_1_wide.dta", clear

* Table C.1 (Study I)
tab age_cat
tab gender
tab edu_cat 
	
*** Fig. C.1: Group Affect (Study I)
cd "$DATA"
use "Study_1.dta", clear

hist sympathy, width(1) by(group, col(3) note("") graphregion(color(white))) percent lcolor(black) fcolor(white)  ///
			   ylabel(0(10)40, angle(0) nogrid) xtitle("") ytitle("% of respondents") xsize(4) ysize(5) 
cd "$FIGURES"
graph export "fig_c1.png", replace
			   

* Table C.2: Group membership and identification (Study 1)
tab belonging_ingroup group_member, col V
bysort group: tab belonging_ingroup group_member, col V


*** Study 2
cd "$DATA"
use "Study_2_wide.dta", clear

* Table C.1 (Study II)
tab age_cat
tab gender
tab edu_cat 
tab region

*** Fig. C.2: Group Affect (Study II)
cd "$DATA"
use "Study_2.dta", clear

hist sympathy_group, width(1) by(group, col(3) note("") graphregion(color(white))) percent lcolor(black) fcolor(white) ///
					 ylabel(0(10)40, angle(0) nogrid) xtitle("") ytitle("% of respondents") xsize(4) ysize(5) 

cd "$FIGURES"
graph export "fig_c2.png", replace


***********************************************************************************************************
*** Appendix D: Average treatment effects
***********************************************************************************************************
***** Results from Study I
cd "$DATA"
use "Study_1.dta", clear

xtset id

*** Pooled models
xtreg evaluation ib2.condition i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_pos
									
xtreg evaluation ib2.condition i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_neg


*** Average marginal effect: positive appeals (Study I)
reg evaluation ib2.condition if group==15
est store m_art_2
reg evaluation ib2.condition if group==3
est store m_disable_2
reg evaluation ib2.condition if group==4
est store m_family_2
reg evaluation ib2.condition if group==6
est store m_homosex_2
reg evaluation ib2.condition if group==9
est store m_pension_2
reg evaluation ib2.condition if group==14
est store m_police_2
reg evaluation ib2.condition if group==7
est store m_rural_2
reg evaluation ib2.condition if group==5
est store m_women_2
	

* Table D.1: Issue-by-issue: positive appeals (Study I)
cd "$TABLES"
esttab m_art_2 m_disable_2 m_family_2 m_homosex_2 m_pension_2 m_police_2 m_rural_2 m_women_2 ///
			 using "tab_d1.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles("Artists" "Disabled people" "Families" "Homosexuals" ///
			 "Senior citizens" "Police officers" "Rural residents" "Women") ///
			 title("Issue-by-issue: positive appeals (Study I)") ///
			 	 order(1.condition 3.condition) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" ) ///
			 scalars("N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)") 
 

*** Average marginal effect: negative appeals (Study I)
reg evaluation ib2.condition if group==1
est store m_car_2
reg evaluation ib2.condition if group==2
est store m_civil_2
reg evaluation ib2.condition if group==11
est store m_crime_2
reg evaluation ib2.condition if group==10
est store m_foreigner_2
reg evaluation ib2.condition if group==12
est store m_muslim_2
reg evaluation ib2.condition if group==13
est store m_politician_2
reg evaluation ib2.condition if group==8
est store m_rich_2


* Table D.3: Issue-by-issue: negative appeals (Study I)
cd "$TABLES"
esttab m_car_2 m_civil_2 m_crime_2 m_foreigner_2 m_muslim_2 m_politician_2 m_rich_2 ///
			 using "tab_d3.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			   eqlabels(none) ///
			 mtitles("Car drivers" "Civil servants" "Criminals" "Foreigners" "Muslims" "Politicians" "Rich people") ///
			 title("Issue-by-issue: negative appeals (Study I)") ///
			 	 order(1.condition 3.condition  ) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" ) ///
			 scalars("N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")			 
 
 
* Group variable
gen gr_id=_n in 1/18
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Artists" 3 "Disabled people" 4 "Families" 5 "Homosexuals" 6 "Pensioners" 7 "Police officers" 8 "Rural residents" 9 "Women" 10 " " 11 "Pooled: negative group appeals" 12 "Car drivers" 13 "Civil servants" 14 "Criminals" 15 "Foreigners" 16 "Muslims" 17 "Politicians" 18 "Rich people" 
label values gr_id  gr_id_lbl


gen gr_sort=1 if gr_id==1
replace gr_sort=2 if gr_id>1 & gr_id<=10
replace gr_sort=3 if gr_id==11
replace gr_sort=4 if gr_id>11 & gr_id<=18

gen treat=.
gen treat_upper=.
gen treat_lower=.	

	
est restore m1_pos
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==1
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==1
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==1

	 
est restore m_art_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==2
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==2
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==2


est restore m_disable_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==3
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==3
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==3


est restore m_family_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==4
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==4
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==4


est restore m_homosex_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==5
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==5
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==5


est restore m_pension_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==6
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==6
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==6


est restore m_police_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==7
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==7
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==7


est restore m_rural_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==8
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==8
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==8

			 
est restore m_women_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==9
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==9
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==9


est restore m1_neg
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==11
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==11
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==11
	 
est restore m_car_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==12
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==12
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==12


est restore m_civil_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==13
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==13
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==13


est restore m_crime_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==14
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==14
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==14


est restore m_foreigner_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==15
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==15
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==15


est restore m_muslim_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==16
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==16
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==16


est restore m_politician_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==17
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==17
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==17


est restore m_rich_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==18
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==18
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==18



*** Treatment effect (non-conditional) for all groups

list gr_id treat in 1/18 
sort gr_sort (treat)
gen gr_id_sort=_n in 1/18
list gr_id treat gr_id_sort in 1/18 
decode gr_id, gen(gr_id_lbl_sort)
*replace gr_id_lbl_sort="" if gr_id==10
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 10 " ", modify
list gr_id treat gr_id_sort in 1/18 , nolabel
list gr_id treat gr_id_sort in 1/18 


twoway (scatter gr_id_sort treat if gr_id_sort>=1 & gr_id_sort<=18, ///
	   title("Study I", color(black))  ytitle(" ") xtitle("Marginal effect: adding group appeal", size(small)) ///
	   graphregion(color(white)) mcolor(black) msize(small) ///
	   ylabel(1(1)18, valuelabel angle(0) notick labsize(small) nogrid) ///
	   xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse) yline(10, lcolor(black))) || ///
	   (rspike treat_upper treat_lower gr_id_sort if gr_id_sort>=1 & gr_id_sort<=18, ///
	   horizontal lcolor(black) legend(off) xsize(6) ysize(5)) 

cd "$FIGURES"
graph save "fig_ate_st1.gph", replace	


***** Study II
cd "$DATA"
use "Study_2.dta", clear

xtset id

*** Pooled models
xtreg evaluation ib1.condition  i.group i.party if positive==1 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_pos
									
xtreg evaluation ib1.condition  i.group i.party if positive==0 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_neg


*** Average treatment effect: positive appeals (Study II)
reg evaluation ib1.condition i.party if item==1
estadd local partyFE "Yes"
est store m_unempl_pos_2
reg evaluation ib1.condition i.party if item==3
estadd local partyFE "Yes"
est store m_art_2
reg evaluation ib1.condition i.party if item==6
estadd local partyFE "Yes"
est store m_car_pos_2
reg evaluation ib1.condition i.party if item==7
estadd local partyFE "Yes"
est store m_homosex_2
reg evaluation ib1.condition i.party  if item==8
estadd local partyFE "Yes"
est store m_muslim_pos_2
reg evaluation ib1.condition i.party if item==12
estadd local partyFE "Yes"
est store m_refugee_2
reg evaluation ib1.condition i.party if item==13
estadd local partyFE "Yes"
est store m_east_2
	

* Table D.2: Issue-by-issue: positive appeals (Study II)
cd "$TABLES"
esttab m_unempl_pos_2 m_car_pos_2  m_muslim_pos_2 m_refugee_2 m_art_2 m_homosex_2 ///
			 using "tab_d2.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles("Unemployed" "Car drivers"   "Muslims"  "Refugees"  "Artists"  "Homosexuals"  "East Germans") ///
			 title("Issue-by-issue: positive appeals (Study II)") ///
			 order(2.condition 3.condition  ) ///
			 drop(*.party) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal" ) ///
             scalars( "partyFE FEs parties"  "N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)") 
 

*** Average marginal effect: negative appeals (Study II) 
reg evaluation ib1.condition i.party if item==2
estadd local partyFE "Yes"
est store m_unempl_neg_2
reg evaluation ib1.condition i.party if item==4
estadd local partyFE "Yes"
est store m_rich_2
reg evaluation ib1.condition i.party if item==5
estadd local partyFE "Yes"
est store m_car_neg_2
reg evaluation ib1.condition i.party if item==11
estadd local partyFE "Yes"
est store m_muslim_neg_2
reg evaluation ib1.condition i.party if item==9
estadd local partyFE "Yes"
est store m_foreigner_2
reg evaluation ib1.condition i.party if item==10
estadd local partyFE "Yes"
est store m_criminals_2


* Table D.4: Issue-by-issue: negative appeals (Study II) 
cd "$TABLES"
esttab m_unempl_neg_2 m_car_neg_2 m_muslim_neg_2 m_foreigner_2 m_rich_2 m_criminals_2  ///
			 using "tab_d4.tex", replace ///
			 se(2) b(a2) nonumbers nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles("Unemployed" "Car drivers" "Muslims" "Foreigners" "Rich people" "Criminals") ///
			 title("Issue-by-issue: negative appeals (Study II)") ///
			 drop(*.party) ///
			 order(2.condition 3.condition ) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal") ///
             scalars("partyFE FEs parties" "N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")

			 
* Group variable
gen gr_id=_n in 1/16
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Unemployed" 3 "Car drivers" 4 "Muslims" 5 "Refugees" 6 "Artists" 7 "Homosexuals" 8 "East Germans" 9 " " 10 "Pooled: negative group appeals" 11 "Unemployed" 12 "Car drivers" 13 "Muslims" 14 "Foreigners" 15 "Rich people" 16 "Criminals" 

gen gr_sort=1 if gr_id==1
replace gr_sort=2 if gr_id>1 & gr_id<=9
replace gr_sort=3 if gr_id==10
replace gr_sort=4 if gr_id>=11 & gr_id<=16


label values gr_id  gr_id_lbl

gen treat=.
gen treat_upper=.
gen treat_lower=.	


est restore m1_pos
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==1
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==1
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==1

	 
est restore m_unempl_pos_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==2
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==2
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==2


est restore m_car_pos_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==3
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==3
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==3


est restore m_muslim_pos_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==4
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==4
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==4


est restore m_refugee_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==5
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==5
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==5


est restore m_art_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==6
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==6
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==6


est restore m_homosex_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==7
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==7
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==7


est restore m_east_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==8
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==8
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==8


			 
est restore m1_neg
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==10
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==10
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==10


est restore m_unempl_neg_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==11
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==11
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==11
	 
est restore m_car_neg_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==12
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==12
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==12


est restore m_muslim_neg_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==13
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==13
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==13


est restore m_foreigner_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==14
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==14
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==14


est restore m_rich_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==15
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==15
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==15


est restore m_criminals_2
margins, dydx(3.condition) post 
matrix b=r(b)
matrix V=e(V)
replace treat=b[1,2] if gr_id==16
replace treat_upper=b[1,2]+1.96*sqrt(V[2,2]) if gr_id==16
replace treat_lower=b[1,2]-1.96*sqrt(V[2,2]) if gr_id==16


	 
*** Figure D.1: Adding group appeals to policy appeals: average marginal effects

list gr_id treat in 1/16
sort gr_sort (treat)
gen gr_id_sort=_n in 1/16
list gr_id treat gr_id_sort in 1/16 
decode gr_id, gen(gr_id_lbl_sort)
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 9 " ", modify
list gr_id treat gr_id_sort in 1/16 , nolabel
list gr_id treat gr_id_sort in 1/16 


twoway (scatter gr_id_sort treat if gr_id_sort>=1 & gr_id_sort<=16, ///
		title("Study II", color(black))  ytitle(" ") ///
		xtitle("Marginal effect: adding group appeal", size(small)) ///
		graphregion(color(white)) mcolor(black) msize(small) ///
		ylabel(1(1)16, valuelabel angle(0) notick labsize(small) nogrid) ///
		xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse) yline(9, lcolor(black))) || ///
		(rspike treat_upper treat_lower gr_id_sort if gr_id_sort>=1 & gr_id_sort<=16, ///
		horizontal lcolor(black) legend(off) xsize(6) ysize(5))
		
cd "$FIGURES"
graph save "fig_ate_st2.gph", replace	
 
graph combine fig_ate_st1.gph fig_ate_st2.gph, graphregion(color(white)) ysize(4) xsize(8) 
graph export "fig_d1.png", replace

erase fig_ate_st1.gph 
erase fig_ate_st2.gph


***********************************************************************************************************
*** Appendix E: Main results
***********************************************************************************************************

***** Study I
cd "$DATA"
use "Study_1.dta", clear

xtset id

*** Regression Table
xtreg evaluation ib2.condition i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_pos

xtreg evaluation ib2.condition##c.sympathy i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_pos

										
xtreg evaluation ib2.condition i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_neg

xtreg evaluation ib2.condition##c.sympathy i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_neg


*** Table E.1: The effect of positive group appeals on statement evaluation (Study I)
cd "$TABLES"
esttab m1_pos m2_pos using "tab_e1.tex", replace ///
			 se(2) b(a2) nonumbers wide nogaps ///
			 nonotes compress label nobaselevels   ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Model 1" "Model 2") ///
			 title("The effect of positive group appeals on statement evaluation (Study I)") ///	 
			 order(1.condition 3.condition sympathy 1.condition#c.sympathy 3.condition#c.sympathy ) ///
			 drop(*.group) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" sympathy "Group affect" ///
			 1.condition#c.sympathy "Group appeal $\times$ Group affect" ///
			 3.condition#c.sympathy "Group-policy appeal $\times$ Group affect") ///
             scalars("respondents FEs respondents" "groupFE FEs groups" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Clustered standard errors (by respondents) in parentheses."  ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")

			 
*** Table E.3: The effect of negative group appeals on statement evaluation (Study I)						 
esttab m1_neg m2_neg using "tab_e3.tex", replace ///
			 se(2) b(a2) nonumbers wide nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Model 1" "Model 2") ///
			 title("The effect of negative group appeals on statement evaluation (Study I)") ///
			 order(1.condition 3.condition sympathy 1.condition#c.sympathy 3.condition#c.sympathy) ///
			 drop(*.group) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" sympathy "Group affect" ///
			 1.condition#c.sympathy "Group appeal $\times$ Group affect" ///
			 3.condition#c.sympathy "Group-policy appeal $\times$ Group affect") ///
			 scalars("respondents FEs respondents" "groupFE FEs groups" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Clustered standard errors (by respondents) in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")	 
			 

***** Study II
cd "$DATA"
use "Study_2.dta", clear

xtset id


*** Regression Tables
xtreg evaluation ib1.condition  i.group i.party if positive==1 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_pos

xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group i.party if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m2_pos

xtreg evaluation ib1.condition##c.sympathy_group i.group i.party if positive==1 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m3_pos
										
xtreg evaluation ib1.condition i.group i.party if positive==0 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m1_neg

xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group i.party if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m2_neg

xtreg evaluation ib1.condition##c.sympathy_group i.group i.party if positive==0 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m3_neg


*** Table E.2: The effect of positive group appeals on statement evaluation (Study II)
cd "$TABLES"
esttab m1_pos m2_pos m3_pos using "tab_e2.tex", replace ///
			 se(2) b(a2) nonumbers wide nogaps ///
			 nonotes compress label nobaselevels   ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Model 1" "Model 2" "Model 3") ///
			 title("The effect of positive group appeals on statement evaluation (Study II)") ///	 
			 order(2.condition 3.condition sympathy_group 2.condition#c.sympathy_group 3.condition#c.sympathy_group ///
			 sympathy_party 2.condition#c.sympathy_party 3.condition#c.sympathy_party) ///
			 drop(*.group *.party) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal" sympathy_group "Group affect" ///
			 2.condition#c.sympathy_group "Value-policy appeal $\times$ Group affect" ///
			 3.condition#c.sympathy_group "Group-policy appeal $\times$ Group affect" /// 
			 sympathy_party "Party affect" 2.condition#c.sympathy_party "Value-policy appeal $\times$ Party affect" ///
			 3.condition#c.sympathy_party "Group-policy appeal $\times$ Party affect") ///
             scalars("respondents FEs respondents" "groupFE FEs groups" "partyFE FEs parties" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Clustered standard errors (by respondents) in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")
			 

*** Table E.4: The effect of negative group appeals on statement evaluation (Study II)
esttab m1_neg m2_neg m3_neg using "tab_e4.tex", replace ///
			 se(2) b(a2) nonumbers wide nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Model 1" "Model 2" "Model 3") ///
			 title("The effect of negative group appeals on statement evaluation (Study II)") ///
			 order(2.condition 3.condition sympathy_group 2.condition#c.sympathy_group 3.condition#c.sympathy_group ///
			 sympathy_party 2.condition#c.sympathy_party 3.condition#c.sympathy_party ) ///
			 drop(*.group *.party) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal" ///
			 sympathy_group "Group affect" 2.condition#c.sympathy_group "Value-policy appeal $\times$ Group affect" ///
			 3.condition#c.sympathy_group "Group-policy appeal $\times$ Group affect" /// 
			 sympathy_party "Party affect" 2.condition#c.sympathy_party "Value-policy appeal $\times$ Party affect" ///
			 3.condition#c.sympathy_party "Group-policy appeal $\times$ Party affect" ) ///
             scalars("respondents FEs respondents" "groupFE FEs groups" "partyFE FEs parties" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Clustered standard errors (by respondents) in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")

			 
***** Value appeals as a placebo test (Study II)
***** Does adding a value appeal have a similar effect?

*** Fig. E.1: Placebo test for positive appeals: Marginal effect of adding value statements
est restore m2_pos
margins, dydx(2.condition) at(sympathy_group=(0(1)10)) 
marginsplot, ///
	addplot((histogram sympathy_group if positive==1, below fintensity(100) color(gs10%30) yaxis(2) ///
	yscale(alt off range(0 3) axis(2)) ytitle("", axis(2)) 	ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') ///
	xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding value appeal ") ///
	xtitle("Group affect") ///
	title(" Study II ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph export "fig_e1.png", replace


*** Fig. E.2: Placebo test for negative appeals: Marginal effect of adding value statements
est restore m2_neg
margins, dydx(2.condition) at(sympathy_group=(0(1)10)) 

marginsplot, ///
	addplot((histogram sympathy_group if positive==0, below fintensity(100) color(gs10%30) yaxis(2) ///
	yscale(alt off range(0 3) axis(2)) ytitle("", axis(2)) ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') ///
	xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding value appeal") ///
	xtitle("Group affect") ///
	title("Study II ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph export "fig_e2.png", replace



*** Fig. E.3: Placebo test for positive appeals: Marginal effect of adding value statements (excl. party affect)
est restore m3_pos
margins, dydx(2.condition) at(sympathy_group=(0(1)10)) 
marginsplot, ///
	addplot((histogram sympathy_group if positive==1, below fintensity(100) color(gs10%30) yaxis(2) ///
	yscale(alt off range(0 3) axis(2)) ytitle("", axis(2)) ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') ///
	xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding value appeal") ///
	xtitle("Group affect") ///
	title(" Study II ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph export "fig_e3.png", replace


*** Fig. E.4: Placebo test for negative appeals: Marginal effect of adding value statements (excl. party affect)
est restore m3_neg
margins, dydx(2.condition) at(sympathy_group=(0(1)10)) 
marginsplot, ///
	addplot((histogram sympathy_group if positive==0, below fintensity(100) color(gs10%30) yaxis(2) ///
	yscale(alt off range(0 3) axis(2)) ytitle("", axis(2)) ylabel(-1(0.5)1, nogrid axis(1)) ///
	ylabel(none, axis(2)) xlabel(0(1)10 0 `" "Do not"  "like at all""' 10 `" "Like" "a lot""') ///
	xscale(range(-0.5 10.5)) )) ///
	graphregion(color(white)) ///
	recast(line) plotopts(lcolor(black)) ///
	recastci(rarea) ciopts(fintensity(30) fcolor(gs4) lcolor(white)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding value appeal") ///
	xtitle("Group affect") ///
	title("Study II ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph export "fig_e4.png", replace


*** Placebo tests: for individual issues (graphs with interaction term)

*** Analyses by groups - positive appeal
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==1 
estadd local partyFE "Yes"
est store m_unempl_pos
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==3 
estadd local partyFE "Yes"
est store m_art
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==6 
estadd local partyFE "Yes"
est store m_car_pos
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==7 
estadd local partyFE "Yes"
est store m_homosex
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==8 
estadd local partyFE "Yes"
est store m_muslim_pos
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==12
estadd local partyFE "Yes"
est store m_refugee
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==13
estadd local partyFE "Yes"
est store m_east

		 
*** Analyses by groups - negative appeal
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party   if item==2
estadd local partyFE "Yes"
est store m_unempl_neg
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party  if item==4
estadd local partyFE "Yes"
est store m_rich
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party  if item==5
estadd local partyFE "Yes"
est store m_car_neg
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party  if item==11
estadd local partyFE "Yes"
est store m_muslim_neg
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party  if item==9
estadd local partyFE "Yes"
est store m_foreigner
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party  if item==10
estadd local partyFE "Yes"
est store m_criminals

 
*** Effects compared to group appeals

gen gr_id=_n in 1/16
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Unemployed" 3 "Car drivers" 4 "Muslims" 5 "Refugees" 6 "Artists" 7 "Homosexuals" 8 "East Germans" 9 " " 10 "Pooled: negative group appeals" 11 "Unemployed" 12 "Car drivers" 13 "Muslims" 14 "Foreigners" 15 "Rich people" 16 "Criminals" 
label values gr_id gr_id_lbl

gen gr_sort=1 if gr_id==1
replace gr_sort=2 if gr_id>1 & gr_id<=9
replace gr_sort=3 if gr_id==10
replace gr_sort=4 if gr_id>=11 & gr_id<=16

gen ME_value=.
gen ME_value_upper=.
gen ME_value_lower=.

gen ME_group=.
gen ME_group_upper=.
gen ME_group_lower=.


* Pooled model
est restore m2_pos
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==1
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==1
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==1

est restore m2_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==1
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==1
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==1



est restore m_unempl_pos
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==2
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==2
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==2

est restore m_unempl_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==2
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==2
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==2



est restore m_car_pos
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==3
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==3
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==3

est restore m_car_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==3
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==3
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==3


est restore m_muslim_pos
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==4
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==4
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==4

est restore m_muslim_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==4
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==4
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==4



est restore m_refugee
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==5
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==5
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==5

est restore m_refugee
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==5
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==5
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==5



est restore m_art
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==6
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==6
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==6

est restore m_art
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==6
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==6
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==6


est restore m_homosex
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==7
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==7
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==7

est restore m_homosex
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==7
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==7
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==7



est restore m_east
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==8
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==8
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==8

est restore m_east
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==8
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==8
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==8




est restore m2_neg
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==10
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==10
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==10

est restore m2_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==10
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==10
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==10

	 
	 
est restore m_unempl_neg
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==11
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==11
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==11

est restore m_unempl_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==11
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==11
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==11


 	 
est restore m_car_neg
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==12
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==12
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==12

est restore m_car_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==12
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==12
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==12


est restore m_muslim_neg
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==13
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==13
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==13

est restore m_muslim_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==13
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==13
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==13


est restore m_foreigner
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==14
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==14
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==14

est restore m_foreigner
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==14
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==14
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==14



est restore m_rich
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==15
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==15
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==15

est restore m_rich
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==15
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==15
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==15



est restore m_criminals
margins, dydx(sympathy_group) at(condition=(1 2)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_value=b[1,1] if gr_id==16
replace ME_value_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==16
replace ME_value_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==16

est restore m_criminals
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==16
replace ME_group_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==16
replace ME_group_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==16

	
gen gr_id_1=gr_id-0.15
gen gr_id_2=gr_id+0.15
	 
	 
twoway (scatter gr_id_1 ME_value  if gr_id>=1 & gr_id<=16, title(" ", color(black)) ytitle(" ") ///
		xtitle("Marginal effect: adding appeal", size(small)) graphregion(color(white)) mcolor(black) msize(small) ///
		ylabel(1 "Pooled: positive group appeals" 2 "Unemployed" 3 "Car drivers" 4 "Muslims" 5 "Refugees" ///
		6 "Artists" 7 "Homosexuals" 8 "East Germans" 9 " " 10 "Pooled: negative group appeals" 11 "Unemployed" ///
		12 "Car drivers" 13 "Muslims" 14 "Foreigners" 15 "Rich people" 16 "Criminals", valuelabel angle(0) /// 
		notick labsize(small) nogrid ) xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse)) ///
		|| (scatter gr_id_2 ME_group  if gr_id>=1 & gr_id<=16, mcolor(gs12) msize(small) symbol(d)) ///
		|| (rspike ME_value_upper ME_value_lower gr_id_1 if gr_id>=1 & gr_id<=16, horizontal ///
		lcolor(black) lpattern(solid) legend(label(1 "Value appeal") label(2 "Group appeal") ///
		order(1 2) size(small)) xsize(5) ysize(6)) ///
		|| (rspike ME_group_upper ME_group_lower gr_id_2 if gr_id>=1 & gr_id<=16, ///
		horizontal lcolor(gs12) lpattern(solid)) 

cd "$FIGURES"
graph export "fig_e5.png", replace
	
	
drop ME* gr_id gr_id*	
label drop gr_id_lbl


***********************************************************************************************************
*** Appendix F: Additional analyses
***********************************************************************************************************


***** Polarizing effects of group appeals
* for Tables F.1 to F.4: see "Main analysis" 


***** Group affect vs. in-group favourability (Study I)

*** Results from Study I
cd "$DATA"
use "Study_1.dta", clear

xtset id
			 
xtreg evaluation ib2.condition##c.sympathy ib2.condition##i.group_member i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_pos_group_control

xtreg evaluation ib2.condition##i.group_member i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_pos_group_control


xtreg evaluation ib2.condition##c.sympathy ib2.condition##i.belonging_ingroup i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_pos_belong_control

xtreg evaluation ib2.condition##i.belonging_ingroup i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_pos_belong_control


xtreg evaluation ib2.condition##c.sympathy ib2.condition##i.group_member i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_neg_group_control

xtreg evaluation ib2.condition##i.group_member i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_neg_group_control


xtreg evaluation ib2.condition##c.sympathy ib2.condition##i.belonging_ingroup i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m1_neg_belong_control
		
xtreg evaluation ib2.condition##i.belonging_ingroup i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_neg_belong_control
		

*** Table F.5: The effect of positive group appeals on statement evaluation		
cd "$TABLES"
esttab m1_pos_group_control m2_pos_group_control m1_pos_belong_control m2_pos_belong_control ///
			 using "tab_f5.tex", replace ///
			 se(2) b(a2) nonumbers nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Accounting for group membership"  "Group membership only" ///
			 "Accounting for group identification"  "Group identification only") ///
			 title("The effect of positive group appeals on statement evaluation") ///
			 order(1.condition 3.condition sympathy 1.condition#c.sympathy 3.condition#c.sympathy ///
			 1.group_member 1.condition#1.group_member 3.condition#1.group_member 1.belonging_ingroup ///
			 1.condition#1.belonging_ingroup 3.condition#1.belonging_ingroup) ///
			 drop(*.group) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" sympathy "Group affect" ///
			 1.condition#c.sympathy "Group appeal $\times$ Group affect" ///
			 3.condition#c.sympathy "Group-policy appeal $\times$ Group affect" 1.group_member "Group member" ///
			 1.belonging_ingroup "Group identification" 1.condition#1.group_member "Group appeal $\times$ Group member" ///
			 3.condition#1.group_member "Group-policy appeal $\times$ Group member" ///
			 1.condition#1.belonging_ingroup "Group appeal $\times$ Group identification" /// 
			 3.condition#1.belonging_ingroup "Group-policy appeal $\times$ Group identification") ///
			 scalars("respondents FEs respondents" "groupFE FEs groups" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Clustered standard errors (by respondents) in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")
	

*** Table F.6: The effect of negative group appeals on statement evaluation
esttab m1_neg_group_control m2_neg_group_control m1_neg_belong_control m2_neg_belong_control ///
			 using "tab_f6.tex", replace ///
			 se(2) b(a2) nonumbers nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Accounting for group membership" "Group membership only" ///
			 "Accounting for group identification" "Group identification only") ///
			 title("The effect of negative group appeals on statement evaluation") ///
			 order(1.condition 3.condition sympathy 1.condition#c.sympathy 3.condition#c.sympathy ///
			 1.group_member 1.condition#1.group_member 3.condition#1.group_member 1.belonging_ingroup ///
			 1.condition#1.belonging_ingroup 3.condition#1.belonging_ingroup) ///
		 	 drop(*.group) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" sympathy "Group affect" ///
			 1.condition#c.sympathy "Group appeal $\times$ Group affect" ///
			 3.condition#c.sympathy "Group-policy appeal $\times$ Group affect" 1.group_member "Group member" ///
			 1.belonging_ingroup "Group identification" 1.condition#1.group_member "Group appeal $\times$ Group member" ///
			 3.condition#1.group_member "Group-policy appeal $\times$ Group member"  ///
			 1.condition#1.belonging_ingroup "Group appeal $\times$ Group identification" ///
			 3.condition#1.belonging_ingroup "Group-policy appeal $\times$ Group identification"  ) ///
			 scalars("respondents FEs respondents"  "groupFE FEs groups" "N Observations" ///
			 "N_g Respondents" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Clustered standard errors (by respondents) in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")


*** Fig. F.1: Marginal effect of adding positive appeals dependent on group membership and identification 
est restore m1_pos_group_control
margins, dydx(3.condition) at(group_member=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `" No member "' 1 `" Group member "') ///
	xscale(range(-0.2 1.2))  ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding positive appeal ") ///
	xtitle("Group membership") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_member_pos.gph",   replace


est restore m1_pos_belong_control
margins, dydx(3.condition) at(belonging_ingroup=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `"No identification"' 1 `"Identification"') ///
	xscale(range(-0.2 1.2))  ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding positive appeal") ///
	xtitle("Group identification") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_belong_pos.gph", replace

graph combine fig_member_pos.gph fig_belong_pos.gph, graphregion(color(white)) ysize(4) xsize(6) ycommon
graph export "fig_f1.png", replace

erase fig_member_pos.gph
erase fig_belong_pos.gph

*** Fig. F.2: Marginal effect of adding negative appeals dependent on group membership and identification
est restore m1_neg_group_control
margins, dydx(3.condition) at(group_member=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `"No member"' 1 `"Group member"') ///
	xscale(range(-0.2 1.2))  ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding negative appeal") ///
	xtitle("Group membership") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_member_neg.gph", replace


est restore m1_neg_belong_control
margins, dydx(3.condition) at(belonging_ingroup=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `"No identification"' 1 `"Identification"') ///
	xscale(range(-0.2 1.2))  ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding negative appeal") ///
	xtitle("Group identification") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_belong_neg.gph", replace

graph combine fig_member_neg.gph fig_belong_neg.gph, graphregion(color(white)) ysize(4) xsize(6) ycommon
graph export "fig_f2.png", replace

erase fig_member_neg.gph
erase fig_belong_neg.gph


*** Fig. F.3: Marginal effect of adding positive appeals dependent on group membership and identification (excl. group affect)
est restore m2_pos_group_control
margins, dydx(3.condition) at(group_member=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `" No member "' 1 `" Group member "') ///
	xscale(range(-0.2 1.2))  ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding positive appeal ") ///
	xtitle("Group membership") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_member_pos_nogroup.gph", replace


est restore m2_pos_belong_control
margins, dydx(3.condition) at(belonging_ingroup=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `"No identification"' 1 `"Identification"') ///
	xscale(range(-0.2 1.2))  ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding positive appeal") ///
	xtitle("Group identification") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_belong_pos_nogroup.gph", replace

graph combine fig_member_pos_nogroup.gph fig_belong_pos_nogroup.gph, graphregion(color(white)) ysize(4) xsize(6) ycommon
graph export "fig_f3.png", replace

erase fig_member_pos_nogroup.gph
erase fig_belong_pos_nogroup.gph



*** Fig. F.4: Marginal effect of adding negative appeals dependent on group membership and identification (excl. group affect)
est restore m2_neg_group_control
margins, dydx(3.condition) at(group_member=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `"No member"' 1 `"Group member"') ///
	xscale(range(-0.2 1.2))  ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding negative appeal") ///
	xtitle("Group membership") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_member_neg_nogroup.gph", replace


est restore m2_neg_belong_control
margins, dydx(3.condition) at(belonging_ingroup=(0 1)) 
marginsplot, ///
	ylabel(-1(0.5)1, nogrid ) ///
	xlabel(0 `"No identification"' 1 `"Identification"') ///
	xscale(range(-0.2 1.2)) ///
	graphregion(color(white)) ///
	recast(scatter) plotopts(mcolor(black)) ///
	recastci(rcap) ciopts(lcolor(gs4)) ///
	yline(0, lcolor(black)) ///
	ytitle("Marginal effect: adding negative appeal") ///
	xtitle("Group identification") ///
	title(" ", color(black)) ///
	legend(off) 

cd "$FIGURES"
graph save "fig_belong_neg_nogroup.gph", replace

graph combine fig_member_neg_nogroup.gph fig_belong_neg_nogroup.gph, graphregion(color(white)) ysize(4) xsize(6) ycommon
graph export "fig_f4.png", replace

erase fig_member_neg_nogroup.gph 
erase fig_belong_neg_nogroup.gph


***** Heterogeneity by issues and parties: Effects for individual issues

*** Study I
*** Results from Study I
cd "$DATA"
use "Study_1.dta", clear

xtset id
			
*** Main analysis
xtreg evaluation ib2.condition##c.sympathy i.group if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_pos

xtreg evaluation ib2.condition##c.sympathy i.group if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
eststo m2_neg	 
		 			
			
*** Analyses by groups - positive appeal
reg evaluation ib2.condition##c.sympathy if group==15
est store m_art
reg evaluation ib2.condition##c.sympathy if group==3
est store m_disable
reg evaluation ib2.condition##c.sympathy if group==4
est store m_family
reg evaluation ib2.condition##c.sympathy if group==6
est store m_homosex
reg evaluation ib2.condition##c.sympathy if group==9
est store m_pension
reg evaluation ib2.condition##c.sympathy if group==14
est store m_police
reg evaluation ib2.condition##c.sympathy if group==7
est store m_rural
reg evaluation ib2.condition##c.sympathy if group==5
est store m_women


*** Table F.7: Issue-by-issue: positive appeals (Study I)
cd "$TABLES"
esttab m_art m_disable m_family m_homosex m_pension m_police m_rural m_women ///
			 using "tab_f7.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Artists" "Disabled people" "Families" "Homosexuals" ///
			 "Senior citizens" "Police officers" "Rural residents" "Women") ///
			 title("Issue-by-issue: positive appeals (Study I)") ///
			 order(1.condition 3.condition sympathy 1.condition#c.sympathy 3.condition#c.sympathy) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" sympathy "Group affect" ///
			 1.condition#c.sympathy "Group appeal $\times$ Group affect" ///
			 3.condition#c.sympathy "Group-policy appeal $\times$ Group affect") ///
			 scalars("N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")

			 		
*** Analyses by groups - negative appeal
reg evaluation ib2.condition##c.sympathy if group==1
est store m_car
reg evaluation ib2.condition##c.sympathy if group==2
est store m_civil
reg evaluation ib2.condition##c.sympathy if group==11
est store m_crime
reg evaluation ib2.condition##c.sympathy if group==10
est store m_foreigner
reg evaluation ib2.condition##c.sympathy if group==12
est store m_muslim
reg evaluation ib2.condition##c.sympathy if group==13
est store m_politician
reg evaluation ib2.condition##c.sympathy if group==8
est store m_rich


*** Table F.9: Issue-by-issue: negative appeals (Study I)
cd "$TABLES"
esttab m_car m_civil m_crime m_foreigner m_muslim m_politician m_rich ///
			 using "tab_f9.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Car drivers" "Civil servants" "Criminals" "Foreigners" "Muslims" "Politicians" "Rich people") ///
			 title("Issue-by-issue: negative appeals (Study I)") ///
			 order(1.condition 3.condition sympathy 1.condition#c.sympathy 3.condition#c.sympathy ) ///
			 varlabels(1.condition "Group appeal" 3.condition "Group-policy appeal" sympathy "Group affect" ///
			 1.condition#c.sympathy "Group appeal $\times$ Group affect" ///
			 3.condition#c.sympathy "Group-policy appeal $\times$ Group affect") ///
			 scalars("N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")			 
 
 
* Group variable
gen gr_id=_n in 1/18
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Artists" 3 "Disabled people" 4 "Families" 5 "Homosexuals" 6 "Pensioners" 7 "Police officers" 8 "Rural residents" 9 "Women" 10 " " 11 "Pooled: negative group appeals" 12 "Car drivers" 13 "Civil servants" 14 "Criminals" 15 "Foreigners" 16 "Muslims" 17 "Politicians" 18 "Rich people" 
label values gr_id  gr_id_lbl


gen gr_sort=1 if gr_id==1
replace gr_sort=2 if gr_id>1 & gr_id<=10
replace gr_sort=3 if gr_id==11
replace gr_sort=4 if gr_id>11 & gr_id<=18


gen ME_group=.
gen ME_upper=.
gen ME_lower=.	


 
*** Marginal effect of group affect depending on policy vs. group-policy appeals			 

* Pooled model
est restore m2_pos
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==1
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==1
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==1

	 
est restore m_art
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==2
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==2
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==2


est restore m_disable
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==3
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==3
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==3


est restore m_family
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==4
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==4
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==4


est restore m_homosex
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==5
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==5
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==5


est restore m_pension
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==6
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==6
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==6


est restore m_police
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==7
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==7
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==7


est restore m_rural
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==8
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==8
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==8

			 
est restore m_women
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==9
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==9
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==9	
		
		
* sort for graph		
list gr_id ME_group in 1/18 
sort gr_sort (ME_group)
gen gr_id_sort=_n in 1/18
list gr_id ME_group gr_id_sort in 1/18 
decode gr_id, gen(gr_id_lbl_sort)
*replace gr_id_lbl_sort="" if gr_id==10
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 10 " ", modify
list gr_id ME_group gr_id_sort in 1/18 , nolabel
list gr_id ME_group gr_id_sort in 1/18 


twoway (scatter gr_id_sort ME_group  if gr_id_sort>=1 & gr_id_sort<=9, ///
		title("Study I", color(black)) ytitle(" ") ///
		xtitle("Marginal effect: adding positive group appeal", size(small)) ///
		graphregion(color(white)) mcolor(black) msize(small) ///
		ylabel(1(1)9, valuelabel angle(0) notick labsize(small) nogrid) ///
		xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse) ) || /// 
		(rspike ME_upper ME_lower gr_id_sort if gr_id_sort>=1 & gr_id_sort<=9, ///
		horizontal lcolor(black) legend(off) xsize(4) ysize(4))

cd "$FIGURES"
graph save "fig_me_issue_pos_st1.gph", replace	


est restore m2_neg
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==11
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==11
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==11
	 
	 
est restore m_car
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==12
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==12
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==12


est restore m_civil
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==13
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==13
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==13


est restore m_crime
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==14
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==14
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==14

est restore m_foreigner
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==15
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==15
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==15

est restore m_muslim
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==16
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==16
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==16

est restore m_politician
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==17
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==17
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==17

est restore m_rich
margins, dydx(sympathy) at(condition=(2 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==18
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==18
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==18
		
 
		
* sort for graph		
drop gr_id_sort gr_id_lbl_sort
label drop gr_id_lbl_sort

list gr_id ME_group in 1/18 
sort gr_sort (ME_group)
gen gr_id_sort=_n in 1/18
list gr_id ME_group gr_id_sort in 1/18 
decode gr_id, gen(gr_id_lbl_sort)
*replace gr_id_lbl_sort="" if gr_id==10
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 10 " ", modify
list gr_id ME_group gr_id_sort in 1/18 , nolabel
list gr_id ME_group gr_id_sort in 1/18 


twoway (scatter gr_id_sort ME_group  if gr_id_sort>=11 & gr_id_sort<=18, ///
		title("Study I", color(black)) ytitle(" ") ///
		xtitle("Marginal effect: adding negative group appeal", size(small)) graphregion(color(white)) ///
		mcolor(black) msize(small)  ylabel(11(1)18, valuelabel angle(0) notick labsize(small) nogrid) /// 
		xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse) ) || ///
		(rspike ME_upper ME_lower gr_id_sort if gr_id_sort>=11 & gr_id_sort<=18, ///
		horizontal lcolor(black) legend(off) xsize(4) ysize(4))

cd "$FIGURES"
graph save "fig_me_issue_neg_st1.gph", replace	
 
 
drop gr_id ME_*      
drop gr_id_sort gr_id_lbl_sort
label drop gr_id_lbl_sort
 
 
*** Study II 

cd "$DATA"
use "Study_2.dta", clear

xtset id


*** Regression Tables
xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group i.party if positive==1, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m2_pos


xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group i.party if positive==0, fe vce(cluster id)
estadd local respondents "Yes"
estadd local groupFE "Yes"
estadd local partyFE "Yes"
eststo m2_neg


reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==1 
estadd local partyFE "Yes"
est store m_unempl_pos
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==3 
estadd local partyFE "Yes"
est store m_art
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==6 
estadd local partyFE "Yes"
est store m_car_pos
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==7 
estadd local partyFE "Yes"
est store m_homosex
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==8 
estadd local partyFE "Yes"
est store m_muslim_pos
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==12
estadd local partyFE "Yes"
est store m_refugee
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==13
estadd local partyFE "Yes"
est store m_east


*** Table F.8: Issue-by-issue: positive appeals (Study II)
cd "$TABLES"
esttab m_unempl_pos m_car_pos  m_muslim_pos m_refugee m_art m_homosex m_east ///
			 using "tab_f8.tex", replace ///
			 se(2) b(a2) nonumbers nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles( "Unemployed" "Car drivers"   "Muslims"  "Refugees"  "Artists"  "Homosexuals"  "East Germans") ///
			 title("Issue-by-issue: positive appeals (Study II)" \label{tab:regression_issue_pos_int_st2}) ///
			 order(2.condition 3.condition sympathy_group 2.condition#c.sympathy_group 3.condition#c.sympathy_group ///
			 sympathy_party 2.condition#c.sympathy_party 3.condition#c.sympathy_party ) ///
			 drop(*.party) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal" sympathy_group "Group affect" ///
			 2.condition#c.sympathy_group "Value-policy appeal $\times$ Group affect" ///
			 3.condition#c.sympathy_group "Group-policy appeal $\times$ Group affect" ///
			 sympathy_party "Party affect" 2.condition#c.sympathy_party "Value-policy appeal $\times$ Party affect" ///
			 3.condition#c.sympathy_party "Group-policy appeal $\times$ Party affect")	///	
             scalars("partyFE FEs parties" "N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")


			 
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==2
estadd local partyFE "Yes"
est store m_unempl_neg
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==4
estadd local partyFE "Yes"
est store m_rich
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==5
estadd local partyFE "Yes"
est store m_car_neg
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==11
estadd local partyFE "Yes"
est store m_muslim_neg
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==9
estadd local partyFE "Yes"
est store m_foreigner
reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.party if item==10
estadd local partyFE "Yes"
est store m_criminals


*** Table F.10: Issue-by-issue: negative appeals (Study II)
cd "$TABLES"
esttab m_unempl_neg m_car_neg m_muslim_neg m_foreigner m_rich m_criminals ///
			 using "tab_f10.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 interaction(" $\times$ ") eqlabels(none) ///
			 mtitles("Unemployed" "Car drivers"   "Muslims" "Foreigners" "Rich people" "Criminals") ///
			 title("Issue-by-issue: negative appeals (Study II)") ///
			 order(2.condition 3.condition sympathy_group 2.condition#c.sympathy_group 3.condition#c.sympathy_group ///
			 sympathy_party 2.condition#c.sympathy_party 3.condition#c.sympathy_party ) ///
			 drop(*.party) ///
			 varlabels(2.condition "Value-policy appeal" 3.condition "Group-policy appeal" ///
			 sympathy_group "Group affect" 2.condition#c.sympathy_group "Value-policy appeal $\times$ Group affect" ///
			 3.condition#c.sympathy_group "Group-policy appeal $\times$ Group affect" ///
			 sympathy_party "Party affect" 2.condition#c.sympathy_party "Value-policy appeal $\times$ Party affect" ///
			 3.condition#c.sympathy_party "Group-policy appeal $\times$ Party affect") ///	
             scalars("partyFE FEs parties" "N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")			 
 
 
 
* Group variable
gen gr_id=_n in 1/16
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Unemployed" 3 "Car drivers" 4 "Muslims" 5 "Refugees" 6 "Artists" 7 "Homosexuals" 8 "East Germans" 9 " " 10 "Pooled: negative group appeals" 11 "Unemployed" 12 "Car drivers" 13 "Muslims" 14 "Foreigners" 15 "Rich people" 16 "Criminals" 

gen gr_sort=1 if gr_id==1
replace gr_sort=2 if gr_id>1 & gr_id<=9
replace gr_sort=3 if gr_id==10
replace gr_sort=4 if gr_id>=11 & gr_id<=16


label values gr_id  gr_id_lbl
gen ME_group=.
gen ME_upper=.
gen ME_lower=.	


* Pooled model
est restore m2_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==1
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==1
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==1


est restore m_unempl_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==2
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==2
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==2


est restore m_car_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==3
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==3
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==3


est restore m_muslim_pos
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==4
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==4
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==4


est restore m_refugee
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==5
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==5
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==5


est restore m_art
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==6
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==6
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==6


est restore m_homosex
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==7
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==7
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==7


est restore m_east
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==8
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==8
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==8

	
* sort for graph		
list gr_id ME_group in 1/16
sort gr_sort (ME_group)
gen gr_id_sort=_n in 1/16
list gr_id ME_group gr_id_sort in 1/16 
decode gr_id, gen(gr_id_lbl_sort)
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 9 " ", modify
list gr_id ME_group gr_id_sort in 1/16 , nolabel
list gr_id ME_group gr_id_sort in 1/16 
	

twoway (scatter gr_id_sort ME_group if gr_id_sort>=1 & gr_id_sort<=8, ///
		title("Study II", color(black)) ytitle(" ") ///
		xtitle("Marginal effect: adding positive group appeal", size(small)) graphregion(color(white)) ///
		mcolor(black) msize(small) ylabel(1(1)8, valuelabel angle(0) notick labsize(small) nogrid) ///
		xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse)) || /// 
		(rspike ME_upper ME_lower gr_id_sort if gr_id_sort>=1 & gr_id_sort<=8, ///
		horizontal lcolor(black) legend(off) xsize(4) ysize(4))

cd "$FIGURES"
graph save "fig_me_issue_pos_st2.gph", replace	

graph combine fig_me_issue_pos_st1.gph fig_me_issue_pos_st2.gph, graphregion(color(white)) xsize(8) ysize(4) xcommon
graph export "fig_f5.png", replace

erase fig_me_issue_pos_st1.gph
erase fig_me_issue_pos_st2.gph

est restore m2_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==10
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==10
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==10
	 
	 
est restore m_unempl_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==11
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==11
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==11

 	 
est restore m_car_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==12
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==12
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==12

est restore m_muslim_neg
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==13
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==13
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==13


est restore m_foreigner
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==14
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==14
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==14


est restore m_rich
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==15
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==15
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==15


est restore m_criminals
margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
matrix b=r(b_vs)
matrix V=e(V_vs)
replace ME_group=b[1,1] if gr_id==16
replace ME_upper=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==16
replace ME_lower=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==16


		
* sort for graph		
drop gr_id_sort gr_id_lbl_sort
label drop gr_id_lbl_sort

list gr_id ME_group in 1/16 
sort gr_sort (ME_group)
gen gr_id_sort=_n in 1/16
list gr_id ME_group gr_id_sort in 1/16 
decode gr_id, gen(gr_id_lbl_sort)
labmask gr_id_sort , values(gr_id_lbl_sort) lblname(gr_id_lbl_sort)
label define gr_id_lbl_sort 9 " ", modify
list gr_id ME_group gr_id_sort in 1/16 , nolabel
list gr_id ME_group gr_id_sort in 1/16 

 
twoway (scatter gr_id_sort ME_group  if gr_id_sort>=10 & gr_id_sort<=16, ///
		title("Study II", color(black)) ytitle(" ") ///
		xtitle("Marginal effect: adding negative group appeal", size(small)) ///
		graphregion(color(white)) mcolor(black) msize(small) ///
		ylabel(10(1)16, valuelabel angle(0) notick labsize(small) nogrid) ///
		xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse)) || ///
		(rspike ME_upper ME_lower gr_id_sort if gr_id_sort>=10 & gr_id_sort<=16, ///
		horizontal lcolor(black) legend(off) xsize(4) ysize(4))

cd "$FIGURES"
graph save "fig_me_issue_neg_st2.gph", replace	

graph combine fig_me_issue_neg_st1.gph fig_me_issue_neg_st2.gph, graphregion(color(white)) xsize(8) ysize(4) xcommon
graph export "fig_f6.png", replace

erase fig_me_issue_neg_st1.gph
erase fig_me_issue_neg_st2.gph
 
drop gr_id gr_sort gr_id_sort ME_* gr_id_lbl_sort
label drop gr_id_lbl gr_id_lbl_sort
 
 

***** Heterogeneity by issues and parties: Effects across parties (Study II)

cd "$DATA"
use "Study_2.dta", clear

xtset id
 
 
sum sympathy_group sympathy_party if condition==3  

xtreg evaluation sympathy_group sympathy_party if positive==1 & condition==3 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local partyFE "No"
estadd local groupFE "No"
eststo group_party_pos_1

xtreg evaluation sympathy_group sympathy_party i.party i.group if positive==1 & condition==3 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local partyFE "Yes"
estadd local groupFE "Yes"
eststo group_party_pos_2

xtreg evaluation sympathy_group sympathy_party if positive==0 & condition==3 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local partyFE "No"
estadd local groupFE "No"
eststo group_party_neg_1

xtreg evaluation sympathy_group sympathy_party i.party i.group if positive==0 & condition==3 & sympathy_party != ., fe vce(cluster id)
estadd local respondents "Yes"
estadd local partyFE "Yes"
estadd local groupFE "Yes"
eststo group_party_neg_2


*** Table F.11: Party vs. group affect (policy-group statements only)
cd "$TABLES"
esttab group_party_pos_1 group_party_pos_2 group_party_neg_1 group_party_neg_2 ///
			 using "tab_f11.tex", replace ///
			 se(2) b(a2) nonumbers  nogaps ///
			 nonotes compress label nobaselevels ///
			 star(* 0.05 ** 0.01 *** 0.001) ///
			 eqlabels(none) ///
			 mtitles( "Positive appeals" "Positive appeals (incl. FEs)" "Negative appeals" "Negative appeals (incl. FEs)") ///
			 title("Party vs. group affect (policy-group statements only)") ///
			 order(sympathy_group sympathy_party  ) ///
			 varlabels(sympathy_group "Group affect" sympathy_party "Party affect")	///	
			 drop(*.party  *.group) ///
             scalars("respondents FEs respondents" "groupFE FEs Groups" "partyFE FEs Parties" ///
			 "N Observations" "r2 R\textsuperscript{2}") ///
			 addnotes("Note: Standard errors in parentheses." ///
			 "\sym{*} \(p<0.5\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)")
			 

*** Fig. F.7: Marginal effects of group affect across parties and issues
* Group variable
gen gr_id=_n in 1/16
label define gr_id_lbl 1 "Pooled: positive group appeals" 2 "Unemployed" 3 "Car drivers" 4 "Muslims" 5 "Refugees" 6 "Artists" 7 "Homosexuals" 8 "East Germans" 9 " " 10 "Pooled: negative group appeals" 11 "Unemployed" 12 "Car drivers" 13 "Muslims" 14 "Foreigners" 15 "Rich people" 16 "Criminals" 
label values gr_id  gr_id_lbl


forval i=1/6  {
	xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group if positive==1 & party==`i', fe vce(cluster id)
	estadd local respondents "Yes"
	estadd local groupFE "Yes"
	eststo m2_pos_`i'

    reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==1 & party==`i' 
	est store m_unempl_pos_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==3 & party==`i' 
	est store m_art_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==6 & party==`i' 
	est store m_car_pos_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==7 & party==`i' 
	est store m_homosex_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==8 & party==`i' 
	est store m_muslim_pos_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==12 & party==`i' 
	est store m_refugee_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==13 & party==`i' 
	est store m_east_`i'

	
	xtreg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party i.group if positive==0 & party==`i', fe vce(cluster id)
	estadd local respondents "Yes"
	estadd local groupFE "Yes"
	eststo m2_neg_`i'
	
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==2 & party==`i' 
	est store m_unempl_neg_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==4 & party==`i' 
	est store m_rich_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==5 & party==`i' 
	est store m_car_neg_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==11 & party==`i' 
	est store m_muslim_neg_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==9 & party==`i' 
	est store m_foreigner_`i'
	reg evaluation ib1.condition##c.sympathy_group ib1.condition##c.sympathy_party if item==10 & party==`i' 
	est store m_criminals_`i'

	gen ME_group_`i'=.
	gen ME_upper_`i'=.
	gen ME_lower_`i'=.

	* Pooled model
	est restore m2_pos_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==1
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==1
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==1


	est restore m_unempl_pos_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==2
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==2
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==2


	est restore m_car_pos_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==3
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==3
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==3


	est restore m_muslim_pos_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==4
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==4
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==4


	est restore m_refugee_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==5
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==5
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==5


	est restore m_art_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==6
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==6
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==6


	est restore m_homosex_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==7
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==7
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==7


	est restore m_east_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==8
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==8
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==8

	
	
	est restore m2_neg_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==10
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==10
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==10
		 
		 
	est restore m_unempl_neg_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==11
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==11
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==11

		 
	est restore m_car_neg_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post 
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==12
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==12
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==12

	est restore m_muslim_neg_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==13
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==13
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==13


	est restore m_foreigner_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==14
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==14
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==14


	est restore m_rich_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==15
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==15
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==15


	est restore m_criminals_`i'
	margins, dydx(sympathy_group) at(condition=(1 3)) pwcompare post
	matrix b=r(b_vs)
	matrix V=e(V_vs)
	replace ME_group_`i'=b[1,1] if gr_id==16
	replace ME_upper_`i'=b[1,1]+1.96*sqrt(V[1,1]) if gr_id==16
	replace ME_lower_`i'=b[1,1]-1.96*sqrt(V[1,1]) if gr_id==16

}

gen gr_id_1=gr_id-0.25
gen gr_id_2=gr_id-0.15
gen gr_id_3=gr_id-0.05
gen gr_id_4=gr_id+0.05
gen gr_id_5=gr_id+0.15
gen gr_id_6=gr_id+0.25
	 
twoway (scatter gr_id_1 ME_group_1  if gr_id>=1 & gr_id<=16, title(" ", color(black)) ytitle(" ") ///
		xtitle("Marginal effect: adding group appeal", size(small)) graphregion(color(white)) ///
		mcolor(black) msize(small)  msymbol(circle) ///
		ylabel(1 "Pooled: positive group appeals" 2 "Unemployed" 3 "Car drivers" 4 "Muslims" ///
		5 "Refugees" 6 "Artists" 7 "Homosexuals" 8 "East Germans" ///
		9 " " 10 "Pooled: negative group appeals" 11 "Unemployed" 12 "Car drivers" ///
		13 "Muslims" 14 "Foreigners" 15 "Rich people" 16 "Criminals", ///
		valuelabel angle(0) notick labsize(small) nogrid) ///
		xlabel(, labsize(small)) xline(0, lcolor(black)) yscale(reverse)) ///
|| (scatter gr_id_2 ME_group_2  if gr_id>=1 & gr_id<=16, mcolor(red) msize(small) msymbol(circle))  ///
|| (scatter gr_id_3 ME_group_3  if gr_id>=1 & gr_id<=16, mcolor(yellow) msize(small) msymbol(circle))  ///
|| (scatter gr_id_4 ME_group_4  if gr_id>=1 & gr_id<=16, mcolor(green) msize(small) msymbol(circle))   ///
|| (scatter gr_id_5 ME_group_5  if gr_id>=1 & gr_id<=16, mcolor(pink) msize(small) msymbol(circle))  ///
|| (scatter gr_id_6  ME_group_6  if gr_id>=1 & gr_id<=16, mcolor(blue) msize(small) msymbol(circle))  ///
|| (rspike ME_upper_1 ME_lower_1 gr_id_1 if gr_id>=1 & gr_id<=16, horizontal lcolor(black) legend(off) xsize(5) ysize(6)) ///
|| (rspike ME_upper_2 ME_lower_2 gr_id_2 if gr_id>=1 & gr_id<=16, horizontal lcolor(red)) ///
|| (rspike ME_upper_3 ME_lower_3 gr_id_3 if gr_id>=1 & gr_id<=16, horizontal lcolor(yellow)) ///
|| (rspike ME_upper_4 ME_lower_4 gr_id_4 if gr_id>=1 & gr_id<=16, horizontal lcolor(green)) ///
|| (rspike ME_upper_5 ME_lower_5 gr_id_5 if gr_id>=1 & gr_id<=16, horizontal lcolor(pink)) ///
|| (rspike ME_upper_6 ME_lower_6 gr_id_6 if gr_id>=1 & gr_id<=16, horizontal lcolor(blue))

cd "$FIGURES"
graph export "fig_f7.png", replace

drop ME* gr_id gr_id*	





***** Open-ended survey questions: Linking policy statements and social groups (data from Study II)
cd "$DATA"
use "Coding_openquestions.dta", clear

* about 20 percent of resp. left the answer blank (99)
tab true

* Table F.12: Analysis of open survey questions
bysort item condition: tab true


ttest correct, by(grouppolicy_vs_policy)
* when group appeal is added, share of correct answers increases by 9 percentage points

bysort item: ttest correct, by(grouppolicy_vs_policy)
* Yet, there are also considerable differences in the magnitude of the effects ranging from +1.7 (`foreigners') to +35.2 percentage points (`unemployed negative').

ttest correct, by(valuepolicy_vs_policy)
* when value appeal is added, share of correct answers does not increase



preserve
collapse (mean) correct (first) statement , by(item condition)

reshape wide correct, i(item) j(condition)
gen diff_share=100*(correct3-correct1)
gen diff_share_value_policy=100*(correct2-correct1)

* re-order items (order as in previous graphs)
gen item2=1 if item==1
replace item2=2 if item==6
replace item2=3 if item==8
replace item2=4 if item==12
replace item2=5 if item==3
replace item2=6 if item==7
replace item2=7 if item==13

replace item2=8 if item==2
replace item2=9 if item==5
replace item2=10 if item==11
replace item2=11 if item==9
replace item2=12 if item==4
replace item2=13 if item==10

graph bar diff_share, horizontal bar(1,color(gs10)) over(item2, ///
					  relabel (1 "Unemployed (positive)" 2 "Car drivers (positive)" ///
					  3 "Muslims (positive)" 4 "Refugees" 5 "Artists" 6 "Homosexuals" ///
					  7 "East Germans" 8 "Unemployed (negative)" 9 "Car drivers (negative)" ///
					  10 "Muslims (negative)" 11 "Foreigners" 12 "Rich people" 13 "Criminals")) ///
					  graphregion(color(white)) ///
					  ytitle("Adding group appeal:" "change in reasonable answers (in %)") ///
					  ylabel(, nogrid) ysize(4) xsize(6)

cd "$FIGURES"
graph export "fig_f8.png", replace


restore
